home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Archives / GNU / GNUPLOTsrc.lha / term / mgr.trm < prev    next >
Encoding:
Text File  |  1996-01-22  |  4.1 KB  |  203 lines

  1. /* GNUPLOT - mgr.trm */
  2. /*
  3.  * This file is included by ../term.c.
  4.  *
  5.  * This terminal driver supports:
  6.  *  Mgr window system, color display
  7.  *
  8.  * AUTHOR
  9.  *  Vincent Broman, broman@nosc.mil
  10.  */
  11. /*
  12.  * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995)
  13.  */
  14.  
  15. #ifndef GOT_DRIVER_H
  16. #include "driver.h"
  17. #endif
  18.  
  19. #ifdef TERM_REGISTER
  20. register_term(mgr)
  21. #endif
  22.  
  23. #ifdef TERM_PROTO
  24. TERM_PUBLIC void MGR_init __P((void));
  25. TERM_PUBLIC void MGR_graphics __P((void));
  26. TERM_PUBLIC void MGR_text __P((void));
  27. TERM_PUBLIC void MGR_linetype __P((int linetype));
  28. TERM_PUBLIC void MGR_move __P((unsigned int x, unsigned int y));
  29. TERM_PUBLIC void MGR_vector __P((unsigned int x, unsigned int y));
  30. TERM_PUBLIC void MGR_put_text __P((unsigned int x, unsigned int y, char *str));
  31. TERM_PUBLIC void MGR_reset __P((void));
  32. #define MGR_XMAX 640
  33. #define MGR_YMAX 400
  34. #define MGR_VCHAR 16
  35. #define MGR_HCHAR 8
  36. #define MGR_VTIC 4
  37. #define MGR_HTIC 4
  38. #endif /* TERM_PROTO */
  39.  
  40. #ifndef TERM_PROTO_ONLY
  41. #ifdef TERM_BODY
  42. #undef ESC
  43. #include <term.h>    /* from Mgr, not gnuplot */
  44.  
  45.  
  46.  
  47. static int MGR_border = 5;
  48. static int MGR_winnbr = 0;
  49.  
  50. static int MGR_rowcount = 24;
  51. static int MGR_winwidth = MGR_XMAX;
  52. static int MGR_winheight = MGR_YMAX;
  53. static int MGR_vchar = MGR_VCHAR;
  54. static int MGR_hchar = MGR_HCHAR;
  55.  
  56.  
  57. TERM_PUBLIC void MGR_init()
  58. {
  59. char res[300];
  60. int winnbr;
  61. int w, h, bor;
  62.  
  63.     m_setup( 0);
  64.     m_ttyset();
  65.  
  66.     m_getinfo( G_SYSTEM);
  67.     if( m_gets( res) && sscanf( res, "%*s%d%d%d", &w, &h, &bor) == 3)
  68.         MGR_border = bor;
  69.  
  70.     m_newwin( 0, 0, MGR_winwidth+2*MGR_border, MGR_winheight+2*MGR_border);
  71.     if( m_gets( res) && sscanf( res, "%d", &winnbr) == 1)
  72.         MGR_winnbr = winnbr;
  73.         /* if no alt window is created, then the main window is used */
  74.         /* and if size is different, term_tbl updated later */
  75.     m_selectwin( MGR_winnbr);
  76.     m_setmode( M_ABS);
  77.  
  78.     m_getinfo( G_FONT);
  79.     if( m_gets( res) && sscanf( res, "%d %d", &w, &h) == 2) {
  80.         MGR_vchar = h;
  81.         MGR_hchar = w;
  82.     }
  83.     m_ttyreset();
  84.  
  85.     term->v_char = MGR_vchar;
  86.     term->h_char = MGR_hchar;
  87.     term->v_tic = MGR_vchar / 4;
  88.     term->h_tic = MGR_hchar / 2;
  89.  
  90.     m_selectwin( 0);
  91.     m_flush();
  92. }
  93.  
  94.  
  95. TERM_PUBLIC void MGR_graphics()
  96. {
  97. char res[32];
  98. int c, r, w, h;
  99.  
  100.     m_selectwin( MGR_winnbr);
  101.     m_setmode( M_ACTIVATE);
  102.     m_clear();
  103.  
  104.     /* we permit the user to reshape the window arbitrarily.
  105.        do_plot calls boundary to recheck the term_tbl for each plot */
  106.     m_ttyset();
  107.     m_getinfo( G_WINSIZE);
  108.     if( m_gets( res) && sscanf( res, "%d %d", &c, &r) == 2)
  109.         MGR_rowcount = r;
  110.     m_getinfo( G_COORDS);
  111.     if( m_gets( res) && sscanf( res, "%d %d %d %d", &c, &r, &w, &h) == 4) {
  112.         term->xmax = MGR_winwidth = w;
  113.         term->ymax = MGR_winheight = h;
  114.     }
  115.     m_ttyreset();
  116.     m_flush();
  117. }
  118.  
  119.  
  120. TERM_PUBLIC void MGR_text()
  121. {
  122.     m_go( 0, 0);
  123.     m_aligntext();
  124.     if( MGR_winnbr == 0)
  125.         m_move( 0, MGR_rowcount - 1);
  126.     m_selectwin( 0);
  127.     m_flush();
  128. }
  129.  
  130.  
  131. TERM_PUBLIC void MGR_linetype( linetype)
  132. int     linetype;
  133. {
  134. /*
  135.  * this mapping of colors is intended for a color sun on which
  136.  * colors 0-23 are defined, 0 is white, 1 is black.
  137.  */
  138.     m_linecolor( B_SRC, (linetype < 0)? 1: (2 + (linetype % 22)));
  139. }
  140.  
  141.  
  142. TERM_PUBLIC void MGR_move( x, y)
  143. unsigned int x, y;
  144. {
  145.     m_go( x, MGR_winheight - 1 - y);
  146. }
  147.  
  148.  
  149. TERM_PUBLIC void MGR_vector( x, y)
  150. unsigned int x, y;
  151. {
  152.     m_draw( x, MGR_winheight - 1 - y);
  153. }
  154.  
  155.  
  156. TERM_PUBLIC void MGR_put_text( x, y, str)
  157. unsigned int x, y;
  158. char *str;
  159. {
  160.     MGR_move( x, y - MGR_vchar/2);
  161.     m_aligntext();
  162.     m_printstr( str);
  163. }
  164.  
  165.  
  166. TERM_PUBLIC void MGR_reset()
  167. {
  168.     m_destroywin( MGR_winnbr);
  169.     MGR_winnbr = 0;
  170.     m_setmode( M_ACTIVATE);
  171.     m_flush();
  172. }
  173.  
  174. #endif /* TERM_BODY */
  175.  
  176. #ifdef TERM_TABLE
  177.  
  178. TERM_TABLE_START(mgr_driver)
  179.     "mgr", "Mgr window system",
  180.     /* dimensions nominal, replaced during MGR_graphics call */
  181.        MGR_XMAX, MGR_YMAX, MGR_VCHAR, MGR_HCHAR, 
  182.        MGR_VTIC, MGR_HTIC, options_null, MGR_init, MGR_reset, 
  183.        MGR_text, null_scale, MGR_graphics, MGR_move, MGR_vector,
  184.        MGR_linetype, MGR_put_text, null_text_angle, 
  185.        null_justify_text, do_point, do_arrow, set_font_null
  186. TERM_TABLE_END(mgr_driver)
  187.  
  188. #undef LAST_TERM
  189. #define LAST_TERM mgr_driver
  190.  
  191. #endif /* TERM_TABLE */
  192. #endif /* TERM_PROTO_ONLY */
  193.  
  194. /*
  195.  * NAME: mgr
  196.  *
  197.  * OPTIONS: none
  198.  *
  199.  * SUPPORTS: Mgr Window system
  200.  *
  201.  * Further Info: don't even now this system
  202.  *
  203.  */